using UnityEngine.UI;
using DG.Tweening;

namespace FutureCorePlugin
{
    public class PreGameSplashUI : BasePreUI<PreGameSplashUI>
    {
        private Image splashImage;

        protected override void OnInit()
        {
            resPath = "Preset/PreUI/GameSplashUI/GameSplashUI";
            uiLayer = PreUIHandler.UILayer.System;
        }

        protected override void OnBind()
        {
            splashImage = uiTF.GetComponent<Image>();
        }

        protected override void OnOpen(object param)
        {
            InitView(param);
        }

        private void InitView(object param)
        {
            float splashTime = (float)param;
            float averageTime = splashTime / 4;
            DOTween.Sequence()
                .Append(splashImage.DOFade(1, averageTime * 2))
                .AppendInterval(averageTime)
                .Append(splashImage.DOFade(0, averageTime));
        }
    }
}